   <?php
   	require_once("../action/connection.php");
	include("cmd/cmd.php");
   $rid="";
   if(isset($_GET['rid']))
		$rid=$_GET['rid'];
		
		
		$msg="";
		if($rid>0){
			if(isset($_POST['btnadd'])){
				$rom=new rooms;
				$rom->r_id=$rid;
				$rom->r_no=$_POST['txtrno'];
				$rom->r_ty=$_POST['txtrty'];
				$rom->r_pr=$_POST['txtrpr'];
												
				$msg=$rom->update_room();				
			}
		}else
		{
			if(isset($_POST['btnadd1'])){
				$rom1=new rooms;
				//$rom->r_id=$rid;
				$rom1->r_no=$_POST['txtrno'];
				$rom1->r_ty=$_POST['txtrty'];
				$rom1->r_pr=$_POST['txtrpr'];
												
				$msg=$rom1->new_room();
						
			}
			
		}
	
	?>
   
    <!--<script>	
		$(document).ready(function(e) {
        	$("#save").click(function(){
				var rno=$("#txtroomno").val();
				var rty=$("#txtroomtype").val();						
				var	rpr=$("#txtroomprice").val();
				
				
				alert(rno+rty+rpr);			
			});
    	});	
	</script>--> 
    
            <h1 class="page-title"><?php if($rid>0) echo "Edit Room"; else echo"New Room"; ?></h1>
            <div> <?php echo $msg; ?> </div>
<div class="btn-toolbar">
       
  <div class="btn-group">
  </div>
</div>
<div class="well">
    
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="home">
      <?php 
	  $query = "SELECT * FROM room_tbl WHERE room_id=$rid"; 
			$result = mysql_query($query);	
			if ( $rid>0){
			while($row = mysql_fetch_array($result)){		
   	?>
    <form id="tab" method="post">
        <label>Room Number</label>
        <input name="txtrno" id="txtroomno" type="text" value="<?php echo $row['room_no']; ?>" class="input-xlarge" required>
        <label>Room Type</label>
        <input name="txtrty" id="txtroomtype" type="text" value="<?php echo $row['room_type']; ?>" class="input-xlarge" required>
        <label>Room Price</label>
        <input name="txtrpr" id="txtroomprice" type="text" value="<?php echo $row['room_price']; ?>" class="input-xlarge" required>
        <br> <button id="save" name="btnadd" class="btn btn-primary"><i class="icon-save"></i> Save</button>                
    </form>
    <?php } }else {?>
    	<form id="tab" method="post">
        <label>Room Number</label>
        <input name="txtrno" id="txtroomno" type="text" value="" class="input-xlarge" required>
        <label>Room Type</label>
        <input name="txtrty" id="txtroomtype" type="text" class="input-xlarge" required>
        <label>Room Price</label>
        <input name="txtrpr" id="txtroomprice" type="text" class="input-xlarge" required>
        <br> <button id="save" name="btnadd1" class="btn btn-primary"><i class="icon-save"></i> Save</button>                
    </form>
    <?php }?>
      </div>
     </div>
  </div>	
  
  
  
    
    
        
    
    
          

                       
		
